/*
 * Instruction41.java
 *
 * Created on March 22, 2007, 8:34 PM
 *
 * COMA
 * (A!) => A, compliment accumulator A
 */

package moto9s12sim;

/**
 *
 * @author Fergus Earnshaw
 */
public class Instruction41 extends Instruction{
    
    /** Creates a new instance of Instruction41 */
    public Instruction41() {
        this.strAssemblyCode = "COMA";
        this.bCodes = new byte[1];
        this.bCodes[0] = (byte)Integer.parseInt("41",16);
    }
    
    public boolean excute(M9S12 cpu)
    {
        this.shAddr = cpu.PC.getRegister();
        cpu.PC.inc();
        
        //INSTRUCTION
        cpu.A.setRegister((byte)~cpu.A.getRegister());
        //set flags
        cpu.CC.setN(cpu.A.getRegister() < 0);
        cpu.CC.setZ(cpu.A.getRegister() == 0);
        cpu.CC.setV(false);        
        cpu.CC.setC(true);

        
        printInstruction(cpu);
        //I think the first invalid instruction should halt excution
        return true;
    }  
    
    
}
